# 属性设置演示
class Student:

    def __init__(self, name, gender):
        self.name = name
        self.__gender = gender

    def gender(self):
        return self.__gender

    def set_gender(self, value):
        self.__gender = value

    @property
    def gender2(self):
        return self.__gender

    @gender2.setter
    def gender2(self, value):
        self.__gender = value


stu = Student("小明", "男")
# 调用实例的方法得到
print(f"{stu.name}", "的性别是", stu.gender())
# 通过属性的设置得到,相当于调用了gender2()的方法
print(f"{stu.name}", "的性别是", stu.gender2)
# 属性的设置
# 使用普通的函数的调用方式
stu.set_gender("女")
print(f"{stu.name}", "的性别是", stu.gender2)
# 使用装饰的方式，进行赋值
stu.gender2 = "男"
print(f"{stu.name}", "的性别是", stu.gender2)
